package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.msg.rest.service.IWxMaMsgTemplateService;
import com.ibeeking.found.msg.service.common.query.WxMaMsgTemplateQuery;
import com.ibeeking.found.msg.service.common.vo.WxMaMsgTemplateVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MsgBaseInfoController控制器
 * @Description 消息基本信息配置
 * @Author ibeeking
 * @Date 2022-01-05 14:41
 **/
@RestController
@RequestMapping("/msg/wxMaMsgTemplate/v1")
public class WxMaMsgTemplateController {

    @Resource
    private IWxMaMsgTemplateService wxMaTemplateServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "小程序订阅消息模板列表")
    @PostMapping(value = "/queryTemplateList")
    public List<WxMaMsgTemplateVO> queryTemplateList(@RequestBody WxMaMsgTemplateQuery pageQuery) {
        return wxMaTemplateServiceImpl.list(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除小程序订阅消息模板")
    @GetMapping(value = "/delTemplate/{id}")
    public Boolean delTemplate(@PathVariable("id") Long id) {
        return wxMaTemplateServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "同步小程序订阅消息模板")
    @PostMapping(value = "/syncWxMaMsgTemplateListFromWx")
    public Integer syncWxMaMsgTemplateListFromWx() {
        return wxMaTemplateServiceImpl.syncWxMaMsgTemplateListFromWx();
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "从微信查询小程序订阅消息模板")
    @PostMapping(value = "/queryMsgTemplateListFromWx")
    public List<TemplateInfo> queryMsgTemplateListFromWx() {
        return wxMaTemplateServiceImpl.queryMsgTemplateListFromWx();
    }

}
